package com.xzq.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
/**
 * 地址实体类
 * @author Adam
 *
 */
@Entity
public class Address implements Serializable {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	@ManyToOne(cascade={CascadeType.MERGE},fetch=FetchType.EAGER)
	@JoinColumn(name="user_id")
	private User user;
	@Column(length=255,nullable=false)
	private String address;
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
	@JoinColumn(name="address_id",insertable=true)
	private Set<Orders> orderses = new HashSet<Orders>();
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Set<Orders> getOrderses() {
		return orderses;
	}
	public void setOrderses(Set<Orders> orderses) {
		this.orderses = orderses;
	}
	public Address() {
		super();
	}
	public Address(Integer id, String address) {
		super();
		this.id = id;
		this.address = address;
	}
	public Address(String address) {
		super();
		this.address = address;
	}
	
}
